package ioc

import (
	"forum/internal/adapter/driving/event/article"
	"forum/internal/domain/event"
	"github.com/IBM/sarama"
)

func InitSaramaClient() sarama.Client {
	config := sarama.NewConfig()
	config.Producer.Return.Successes = true
	client, err := sarama.NewClient([]string{"localhost:9092"}, config)
	if err != nil {
		panic(err)
	}
	return client
}

func InitProducer(client sarama.Client) sarama.SyncProducer {
	producer, err := sarama.NewSyncProducerFromClient(client)
	if err != nil {
		panic(err)
	}
	return producer
}

func InitConsumers(consumer *article.BatchReadCntConsumer) []event.Consumer {
	return []event.Consumer{consumer}
}
